<?php
function createthumb($name,$file,$maxsize)
{
  list($width, $height) = getimagesize("$name/$file");
  $width = min($width, $height);
  $tn = imagecreatetruecolor($maxsize, $maxsize);
  $image = imagecreatefromjpeg("$name/$file");
  imagecopyresampled($tn, $image, 0, 0, 0, 0, $maxsize, $maxsize, $width, $width);
  imagejpeg($tn, "$name/thumbnails/tn_$file", 70);
  return true;
}
?>
